package com.hongxun.design.utils;

/**
 * Created by zerdoor_pc .
 * author:dc
 * 2016/12/30.
 */

public class StringUtil {
    public static String getNumber(String str) {
        String suffix = "";
        String num = "";
        if (str.length() > 0) {
            for (int i = 0; i < str.length(); i++) {
                char temp = str.charAt(i);
                try {

                    Integer tempnum = Integer.parseInt(String.valueOf(temp));
                    num += String.valueOf(tempnum);
                } catch (NumberFormatException e) {
                    num = "";
                }

            }
        }
        if (num.length() > 0) {
            int newNum = Integer.parseInt(num) + 1;
            String newHead;
            if (str.length() > (num.length())) {
                newHead = str.substring(0, str.length() - num.length());
                return newHead + newNum;
            } else {
                return null;
            }

        } else {
            return null;
        }


    }

    public static boolean isEmpty(String str) {
        return str == null || str.length() == 0;
    }

    public static String getNull(String str) {
        if (isEmpty(str)) return "";
        else return str;
    }
}
